#include "CREATE_VARIABLE.h"
#include <iostream>
#include <cassert>
#include "Expression.h"
#include "DataHolderGarbageCollector.h"

using namespace std;

CREATE_VARIABLE_Instruction::CREATE_VARIABLE_Instruction(const string& variableName, Expression* assignExpression) {

	assert(variableName != "");
	assert(assignExpression != NULL);
	
	m_type = CREATE_VARIABLE;
	m_variableName = variableName;
	m_expression = assignExpression;
	
	DHGC->addReferencer(this);
}

CREATE_VARIABLE_Instruction::~CREATE_VARIABLE_Instruction() {
	DHGC->removeReferencer(this);
}

const string& CREATE_VARIABLE_Instruction::getVariableName() {
	assert(m_variableName != "");
	return m_variableName;
}

Expression* CREATE_VARIABLE_Instruction::getVariableExpression() {
	assert(m_expression);
	return m_expression;
}

void CREATE_VARIABLE_Instruction::setDataHoldersToReferenced() {	
	assert(m_expression);
	m_expression->setReferenced(true);
}
